<!DOCTYPE HTML>
<html>

<head>
	<link rel="bookmark"  type="image/x-icon"  href="/img/logo_miccall.png"/>
	<link rel="shortcut icon" href="/img/logo_miccall.png">
	
			    <title>
    Ame雨
    </title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <link rel="stylesheet" href="/amelin-ting/css/mic_main.css" />
    <link rel="stylesheet" href="/amelin-ting/css/dropdownMenu.css" />
    <meta name="keywords" content="Ame雨" />
    
    	<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
	 
    <noscript>
        <link rel="stylesheet" href="/amelin-ting/css/noscript.css" />
    </noscript>
    <style type="text/css">
        body:before {
          content: ' ';
          position: fixed;
          top: 0;
          background: url('/amelin-ting/img/bg.jpg') center 0 no-repeat;
          right: 0;
          bottom: 0;
          left: 0;
          background-size: cover; 
        }
    </style>

			    
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script async type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


    <script src="/amelin-ting/js/jquery.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrollex.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrolly.min.js"></script>
    <script src="/amelin-ting/js/skel.min.js"></script>
    <script src="/amelin-ting/js/util.js"></script>
    <script src="/amelin-ting/js/main.js"></script>
	
<meta name="generator" content="Hexo 5.4.0"></head>
    
		
<!-- Layouts -->



<!--  代码渲染  -->
<link rel="stylesheet" href="/css/prism_coy.css" />
<link rel="stylesheet" href="/css/typo.css" />
<!-- 文章页 -->
<body class="is-loading">
    <!-- Wrapper 外包 s-->
    <div id="wrapper" class="fade-in">
        <!-- Intro 头部显示 s -->
        <!-- Intro 头部显示 e -->
        <!-- Header 头部logo start -->
        <header id="header">
    <a href="/amelin-ting/" class="logo">Art Space</a>
</header>
        <!-- Nav 导航条 start -->
        <nav id="nav" class="special" >
            <ul class="menu links" >
			<!-- Homepage  主页  --> 
			<li >
	            <a href="/amelin-ting/" rel="nofollow">主页</a>
	        </li>
			<!-- categories_name  分类   --> 
	        
	        <li class="active">
	            <a href="#s1">分类</a>
	                    <ul class="submenu">
	                        <li>
	                        <a class="category-link" href="/amelin-ting/categories/Go/">Go</a></li><li><a class="category-link" href="/amelin-ting/categories/django/">django</a></li><li><a class="category-link" href="/amelin-ting/categories/drf/">drf</a></li><li><a class="category-link" href="/amelin-ting/categories/gin/">gin</a></li><li><a class="category-link" href="/amelin-ting/categories/go/">go</a></li><li><a class="category-link" href="/amelin-ting/categories/linux/">linux</a></li><li><a class="category-link" href="/amelin-ting/categories/mysql/">mysql</a></li><li><a class="category-link" href="/amelin-ting/categories/python/">python</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/">内网穿透</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%89%8D%E7%AB%AF/">前端</a>
	                    </ul>
	        </li>
	        
	        <!-- archives  归档   --> 
	        
	        
		        <!-- Pages 自定义   -->
		        
		        <li>
		            <a href="/about/" title="简历">
		                简历
		            </a>
		        </li>
		        
		        <li>
		            <a href="/group/" title="团队">
		                团队
		            </a>
		        </li>
		        
		        <li>
		            <a href="/gallery/" title="图库">
		                图库
		            </a>
		        </li>
		        
		        <li>
		            <a href="/tag/" title="标签">
		                标签
		            </a>
		        </li>
		        


            </ul>
            <!-- icons 图标   -->
			<ul class="icons">
                    
                    <li>
                        <a title="github" href="https://github.com/miccall" target="_blank" rel="noopener">
                            <i class="icon fa fa-github"></i>
                        </a>
                    </li>
                    
                    <li>
                        <a title="500px" href="http://500px.com" target="_blank" rel="noopener">
                            <i class="icon fa fa-500px"></i>
                        </a>
                    </li>
                    
			</ul>
</nav>

        <div id="main" >
            <div class ="post_page_title_img" style="height: 25rem;background-image: url(https://img1.baidu.com/it/u=3272449815,2870615706&amp;fm=26&amp;fmt=auto);background-position: center; background-repeat:no-repeat; background-size:cover;-moz-background-size:cover;overflow:hidden;" >
                <a href="#" style="padding: 4rem 4rem 2rem 4rem ;"><h2 >linux基础</h2></a>
            </div>
            <!-- Post -->
            <div class="typo" style="padding: 3rem;">
                <h1 id="linux基础"><a href="#linux基础" class="headerlink" title="linux基础"></a>linux基础</h1><h2 id="一-虚拟机管理软件"><a href="#一-虚拟机管理软件" class="headerlink" title="一 虚拟机管理软件"></a>一 虚拟机管理软件</h2><p>​    虚拟机<br>​    vmware workstation<br>​    windows系统<br>​    计算机硬件<br>​<br>​<br>​<br>​    虚拟机<br>​    libvirtd<br>​    linux（kvm）<br>​    计算机硬件</p>
<p>   虚拟机<br>   esxi<br>   计算机硬件</p>
<h2 id="二-虚拟机管理软件的三种网络模式"><a href="#二-虚拟机管理软件的三种网络模式" class="headerlink" title="二 虚拟机管理软件的三种网络模式"></a>二 虚拟机管理软件的三种网络模式</h2><p>​    NAT（vmnet8）：虚拟机之间、以及与真机之间可以通信，并且虚拟机还可以访问外网<br>​                   特点：虚拟机可以访问外网，真机以外的机器都是外网，真机以外的机器不能主动访问虚拟机<br>​<br>​                   ps：虚拟机的ip地址不会与真实的网络环境冲突<br>​    仅主机模式（vmnet1）：只能虚拟机之间、以及与真机之间通信，无法与外界通信<br>​    </p>
<p>​    桥接模式（本地以太网卡）：相当于虚拟机直接连接到真正的交换机上<br>​                   特点：虚拟机可以访问外网，真机可以连接虚拟机<br>​                   ps：虚拟机的ip地址容易与真实的网络环境冲突</p>
<p>​<br>​<br>​    vi /etc/sysconfing/network-scripts/ifcfg-ens32<br>​    按：i<br>​    上下键移动到ONBOOT那一行，修改ONBOOT=yes<br>​    按ESC<br>​    按shift+冒号<br>​    输入wq，回车</p>
<p>​<br>​    执行命令<br>​    systemctl restart network<br>​    </p>
<pre><code>ip a
</code></pre>
<p>​    </p>
<h2 id="三-基础命令"><a href="#三-基础命令" class="headerlink" title="三 基础命令"></a>三 基础命令</h2><p>​    ctrl + l 清屏<br>​    </p>
<h2 id="四-操作系统启动流程"><a href="#四-操作系统启动流程" class="headerlink" title="四 操作系统启动流程"></a>四 操作系统启动流程</h2><pre><code>加电-》bios-》MBR（启动盘的第一个扇区，512个字节，446引导程序，64分区信息，2结束的标志位）

-》bootloader（grub是一种具体的bootloader程序）

-》grub负责把操作系统内核加载到内存

-》

centos6：init （pid为0）
centos7：systemd（pid为0）

-》七种启动级别
- 0:关机 poweroff.target
- 1:单用户模式 rescue.target
- 2:多用户模式(没有文件系统，没有网络) multi-user.target
- 3:多用户模式(命令行) multi-user.target
- 4:没有被使用 multi-user.target
- 5:图形化界面 graphical.target
- 6:重启 reboot.target
</code></pre>
<h2 id="一、操作系统相关"><a href="#一、操作系统相关" class="headerlink" title="一、操作系统相关"></a>一、操作系统相关</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&quot;&quot;&quot;破解单用户密码&quot;&quot;&quot;</span></span><br><span class="line"><span class="comment"># 咳咳 不能说是破解，万一自己把自己的密码忘了是吧，我们总不能重装一个系统，所以我们就得去重新设置这个密码</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">	首先我们来想，电脑开机，先会启动BIOS，在启动Grup，我们应该在哪个阶段去操作呢，是在grup整合后，在选择操作系统界面上去操作,按住‘e’，然后进入了一大串英文的界面，不要慌，信Ame汀哥得永生，我们用上下键去找到一个 ro 英文字母的地方，把o改成w，然后写入init=/sysroot/bin/sh 在按下 ctrl+e 进入单用户模式，然后这时候 就执行chroot /sysroot。其中chroot命令用来切换系统，/sysroot/目录就是原始系统 ，在输入passwd，随后就可以改密码啦，输入完两次后，要记得保存哦，touch /.autorelabel，这个输入完就保存啦，然后正常重启即可</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="comment"># 那这个能破解的话，我们可以采用Grup加密的方式，来防止这个的破解，道高一尺魔高一丈</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">	Grup怎么加密呢</span></span><br><span class="line"><span class="string">1) 执行 grub2-setpassword 命令</span></span><br><span class="line"><span class="string"># grub2-setpassword</span></span><br><span class="line"><span class="string">Enter password:</span></span><br><span class="line"><span class="string">Confirm password:</span></span><br><span class="line"><span class="string">2）如果现在重新启动系统并尝试修改引导条目，系统将要求提供凭据，但是可以在没有凭据的情况下修改引导条目。为了阻止未经授权的修改和未经授权的启动，我们需要对 /boot/grub2/grub.cfg 文件进行更改</span></span><br><span class="line"><span class="string">打开文件并使用密码搜索需要保护的启动条目，它以menuentry开头。找到条目后，从中删除 --unrestricted 参数</span></span><br><span class="line"><span class="string">3) reboot 重启验证，只有当输入正确的用户名和密码时，才能进入 grub 菜单或者修改引导条目。</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="comment"># 大家们要注意没有百分百的安全，我们能Grup加密，也能用光盘修复模式来绕过这个Grup加密</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">	光盘修复模式</span></span><br><span class="line"><span class="string">#1、进入bios、从光盘启动</span></span><br><span class="line"><span class="string">#2、点击Troubleshooting</span></span><br><span class="line"><span class="string">#3、进入到Troubleshooting界面         选择：Rescue a CentOS Linux system</span></span><br><span class="line"><span class="string">#4、三:进入到Rescue选项   按 ENTER键 选1 ，其他选项意思如下</span></span><br><span class="line"><span class="string">1)continue:救援模式程序会自动查找系统中已有的文件系统，并可读写挂载到/mnt/sysimage目录下。</span></span><br><span class="line"><span class="string">2)Read-Only:会以只读的方式挂载已有的文件系统。</span></span><br><span class="line"><span class="string">3)Skip to shell: 手动挂载  </span></span><br><span class="line"><span class="string">#5、sh切换bash模式</span></span><br><span class="line"><span class="string">chroot /mnt/sysimage/</span></span><br><span class="line"><span class="string">#6、执行命令</span></span><br><span class="line"><span class="string">passwd root</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="comment"># 我们又能用BIOS加密来防止这个光盘修复模式，但是大家想还有没有破解方法呢,肯定有呀，所以说没有百分百安全的东西</span></span><br><span class="line">	</span><br></pre></td></tr></table></figure>

<h2 id="二、Shell基础命令"><a href="#二、Shell基础命令" class="headerlink" title="二、Shell基础命令"></a>二、Shell基础命令</h2><h3 id="1-基本命令语法"><a href="#1-基本命令语法" class="headerlink" title="1. 基本命令语法"></a>1. 基本命令语法</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 一个最完整的语法是由 命令 选项 参数</span> </span><br><span class="line">				    cd   -l  /boot</span><br><span class="line">	要记住命令是必须在的，选项和参数是可选存在的，不写选项和命令是会有默认值的，所以 cd 其他都不加就是会打开当前文件夹</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="2-基本命令"><a href="#2-基本命令" class="headerlink" title="2. 基本命令"></a>2. 基本命令</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">1.pwd：会观察当前所在文件夹的路径</span><br><span class="line">2.ls:  会告诉你当前文件夹之下的子文件夹(默认参数情况下)</span><br><span class="line">3.cd /参数:  会打开你想要的文件夹</span><br><span class="line">4.data： 有关于时间的命令，默认情况下会给你当前时间</span><br><span class="line"><span class="meta">	#</span><span class="bash"> 要知道国际上有一个网站是统一的时间网站，这里面的时间是最统一的</span></span><br><span class="line">	ntpdata ntp1.aliyun.com  # 这个就会把系统时间给调整成准确时间</span><br><span class="line">	hwclock  # 这个就是调整系统时间</span><br><span class="line">    #  注意，在电脑开机的时候，是由操作系统控制着时间，当电脑关机后，时间就有硬件去操控计算时间，当电脑下次开机的时候，硬件就	会把当前时间传给操作系统，让操作系统去掌管，操作系统会隔一段时间就会把当前时间传给硬件，所以并不是，系统时间已改，硬件的时间	也会改</span><br><span class="line">5.重启</span><br><span class="line">	5.1 shutdown -r 0  # 立即重启</span><br><span class="line">	5.2 shutdown -r now  # 立即重启</span><br><span class="line">	5.3 shutdown -r 5  # 5MIN后重启</span><br><span class="line">	5.4 shutdown -r 11.30  # 11.30的时候重启</span><br><span class="line">	5.5 init 6  # 操作系统启动级别</span><br><span class="line">	5.6 reboot</span><br><span class="line">6.关机</span><br><span class="line">	6.1 shutdown -h 0  # 立即关机</span><br><span class="line">	6.2 shutdown -h now  # 立即关机</span><br><span class="line">	6.3 init 0  # 操作系统启动级别</span><br><span class="line">	6.4 poweroff</span><br><span class="line">7.退出</span><br><span class="line">	7.1 ctrl+d</span><br><span class="line">	7.2 logout</span><br><span class="line">	7.3 exit</span><br><span class="line">8.取消</span><br><span class="line">	shutdown -c</span><br><span class="line">9.查看操作系统</span><br><span class="line">	9.1 uname -a  # 查看操作系统的很多信息 比如 内核版本 主机名 ...</span><br><span class="line">	9.2 uname -r  # 查看操作系统内核版本</span><br><span class="line">	9.3 cat /etc/redhat-release  #查看操作系统版本</span><br><span class="line">10.查看文件内容</span><br><span class="line">	cat /参数</span><br></pre></td></tr></table></figure>

<h2 id="3-bash的特性"><a href="#3-bash的特性" class="headerlink" title="3.bash的特性"></a>3.bash的特性</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">1. 命令和文件的自动补全  Tab</span><br><span class="line"><span class="meta">	#</span><span class="bash"> 注意 Tab只能补全命令和文件</span></span><br><span class="line">2. ctrl + c  # 退出前台正在运行的程序</span><br><span class="line">3. ctrl + d  # 退出，相当于exit</span><br><span class="line">4. ctrl + l  # 清空命令行</span><br><span class="line">5. ctrl + a  # 指针到最前面</span><br><span class="line">6. ctrl + e  # 指针到最后面</span><br><span class="line">7. ctrl + r  # 利用关键字 来寻找历史命令</span><br><span class="line">8. !$  # 打印上一个命令的参数  也可以 Alt +</span><br><span class="line">9. 查看历史命令  history</span><br><span class="line">	9.1 history -c  # 清空历史命令</span><br><span class="line">	9.2 history 10  # 显示出最近的十行历史命令，是从下往上显示，因为是最近！！</span><br><span class="line">	9.3 cat ~/.bash_history  # 这个是查看历史命令保存文件</span><br><span class="line">	&quot;&quot;&quot;亲身经历，如果没有这个文件夹，是因为你没有用shutdown -r正常的重启系统，重启一下，系统则会自动帮你的历史命令存入硬盘，就有了文件，还有这个是隐藏文件&quot;&quot;&quot;</span><br><span class="line">	9.4 修改历史命令文件</span><br><span class="line">		9.4.1 光标上下</span><br><span class="line">		9.4.2 光标上下键</span><br><span class="line">         9.4.3 ^r //搜索历史命令(输入一段某条命令的关键字：必须是连续的)</span><br><span class="line">         9.4.4 !220  执行历史命令中第220条命令</span><br><span class="line">         9.4.5 !字符串  搜索历史命令中最近一个以xxxx字符开头的命令，例如!ser</span><br><span class="line">         9.4.6 !$  引用上一个命令的最后一个参数</span><br></pre></td></tr></table></figure>

<h2 id="4-命令的别名"><a href="#4-命令的别名" class="headerlink" title="4.命令的别名"></a>4.命令的别名</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># alias //查看系统当前的别名</span></span><br><span class="line"><span class="comment"># alias egon=&#x27;ls /etc/sysconfig/network-scripts/&#x27; //建立别名</span></span><br></pre></td></tr></table></figure>

<h2 id="一、操作系统的单-多根目录结构"><a href="#一、操作系统的单-多根目录结构" class="headerlink" title="一、操作系统的单/多根目录结构"></a>一、操作系统的单/多根目录结构</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">	我们先来看我们经常用的操作系统-----windows    windows我们会经常用c盘来当系统盘，存储系统文件，而D/E...就是来我们自由分配其他文件啦，所以操作系统是多根目录结构，有很多盘，但是其实盘也就是文件夹的概念</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">	我们在来看linux系统，Linux系统就是单根目录结构，他根目录就是/</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br></pre></td></tr></table></figure>



<h2 id="二、绝对路径与相对路径"><a href="#二、绝对路径与相对路径" class="headerlink" title="二、绝对路径与相对路径"></a>二、绝对路径与相对路径</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 绝对路径  比如  /root/a/b/c.txt  就好比你在太阳系地球中国上海xxx小区xxx栋xxx楼，这种的就是绝对路径，化成灰也能找到你</span></span><br><span class="line"><span class="comment"># 相对路径  比如  你当前文件夹在a的时候 b/c.txt 就好了，就好比你的朋友就在你隔壁第三排第一座，是相对你来说</span></span><br></pre></td></tr></table></figure>

<h2 id="三、玉女心经之文件管理之中之基础命令"><a href="#三、玉女心经之文件管理之中之基础命令" class="headerlink" title="三、玉女心经之文件管理之中之基础命令"></a>三、玉女心经之文件管理之中之基础命令</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> pwd  <span class="comment"># 可以观察当前文件夹的绝对路径</span></span><br><span class="line"><span class="number">2.</span> ls  <span class="comment"># 默认可以观察当前文件夹的子文件夹</span></span><br><span class="line">	<span class="number">2.1</span> ls -l  <span class="comment"># 可以详细的显示出子文件夹的信息</span></span><br><span class="line">    <span class="number">2.2</span> ls -a  <span class="comment"># 可以显示出全部的文件 文件夹（包括隐藏文件夹）</span></span><br><span class="line">    <span class="number">2.3</span> ls -al  <span class="comment"># 两种综合起来显示</span></span><br><span class="line">    <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    drwxr-xr-x.  19 root root 3160 6月  23 14:50 dev</span></span><br><span class="line"><span class="string">		我们首先来看d d的意思是这是文件夹，所以第一个字母就是文件类型的意思</span></span><br><span class="line"><span class="string">		然后我们来看rwx 这是说明在主权限下，这个文件夹可以读&amp;写&amp;操作</span></span><br><span class="line"><span class="string">		r-x这是说明在组的方面可以做读&amp;操作</span></span><br><span class="line"><span class="string">		最后的r-x这是说明在其他用户的权限下可以做读&amp;操作</span></span><br><span class="line"><span class="string">		最后有一个. 这是selinux的文件，这个是美国空兵为了数据的安全性写的直接加入linux内核中，自然安全性提高了，但是运行效率降低了，所以我们平时用需要把selinux给关闭</span></span><br><span class="line"><span class="string">		19              硬链接个数</span></span><br><span class="line"><span class="string">         root            属主</span></span><br><span class="line"><span class="string">         root            属组</span></span><br><span class="line"><span class="string">         3160            文件大小，单位字节</span></span><br><span class="line"><span class="string">         6月  23 14:50   文件修改时间</span></span><br><span class="line"><span class="string">         dev             文件名字</span></span><br><span class="line"><span class="string">    权限的第一个为代表文件类型</span></span><br><span class="line"><span class="string">        格式         说明</span></span><br><span class="line"><span class="string">        -            普通文件(文本,    二进制,    压缩包,    图片,    日志等)    </span></span><br><span class="line"><span class="string">        d            目录文件</span></span><br><span class="line"><span class="string">        b            设备文件(块设备)存储设备硬盘    /dev/sda1,    /dev/sda2</span></span><br><span class="line"><span class="string">        c            设备文件(字符设备)打印机，终端    /dev/tty1,    /dev/zero</span></span><br><span class="line"><span class="string">        s            套接字文件,    进程间通信(socket)</span></span><br><span class="line"><span class="string">        p            管道文件</span></span><br><span class="line"><span class="string">        l            链接文件	</span></span><br><span class="line"><span class="string">	注意: Linux文件扩展名不代表任何含义, 仅仅是为了运维人员便于识别</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br><span class="line"><span class="number">3.</span> cd  <span class="comment"># 可以切换目录 </span></span><br><span class="line">	<span class="number">3.1</span> cd /绝对路径</span><br><span class="line">    <span class="number">3.2</span> cd /相对路径</span><br><span class="line">    <span class="number">3.3</span> cd .  <span class="comment"># 一个点是当前文件夹不变</span></span><br><span class="line">    <span class="number">3.4</span> cd ..  <span class="comment"># 两个点是上一级文件夹，那上上级就是 cd ../..</span></span><br><span class="line">    <span class="number">3.5</span> cd  <span class="comment"># 默认是回家，回到管理员文件夹</span></span><br><span class="line">    <span class="number">3.6</span> cd -  <span class="comment"># 这个是返回上次目录</span></span><br><span class="line"><span class="number">4.</span> tree  <span class="comment"># 查看目录树</span></span><br><span class="line">	<span class="string">&quot;&quot;&quot;在此之前得说明如果你tree 查无命令  就得输入yum install tree来下载&quot;&quot;&quot;</span></span><br><span class="line">    <span class="number">4.1</span> tree -a  <span class="comment"># tree会把所有文件夹 文件显示出来 包括隐藏文件</span></span><br><span class="line">    <span class="number">4.2</span> tree -d  <span class="comment"># tree会只把文件夹显示出来（不包括隐藏文件夹）</span></span><br><span class="line">    <span class="number">4.3</span> tree -L <span class="number">1</span>  <span class="comment"># 后面数字 比如说是1，tree就只会显示层级1的文件夹，子子文件夹就不会显示了</span></span><br><span class="line">    <span class="number">4.4</span> tree -F  <span class="comment"># 在条目后加上文件类型的指示符号,例如会在显示出的目录后面加上左斜杠/</span></span><br><span class="line">    <span class="string">&quot;&quot;&quot;以下内容非本人扩展，转自我们的伟大的矮跟老师,欢呼 芜湖~~~~~~~~~~~~~~~~~~~~~~~~~~~~&quot;&quot;&quot;</span></span><br><span class="line">    <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    了解一下tree命令其他选项</span></span><br><span class="line"><span class="string">    -a 显示所有文件和目录。</span></span><br><span class="line"><span class="string">    -A 使用ASNI绘图字符显示树状图而非以ASCII字符组合。</span></span><br><span class="line"><span class="string">    -C 在文件和目录清单加上色彩，便于区分各种类型。</span></span><br><span class="line"><span class="string">    -d 显示目录名称而非内容。</span></span><br><span class="line"><span class="string">    -D 列出文件或目录的更改时间。</span></span><br><span class="line"><span class="string">    -f 在每个文件或目录之前，显示完整的相对路径名称。</span></span><br><span class="line"><span class="string">    -F 在执行文件，目录，Socket，符号连接，管道名称名称，各自加上&quot;*&quot;,&quot;/&quot;,&quot;=&quot;,&quot;@&quot;,&quot;|&quot;号。</span></span><br><span class="line"><span class="string">    -g 列出文件或目录的所属群组名称，没有对应的名称时，则显示群组识别码。</span></span><br><span class="line"><span class="string">    -i 不以阶梯状列出文件或目录名称。</span></span><br><span class="line"><span class="string">    -I 不显示符合范本样式的文件或目录名称。</span></span><br><span class="line"><span class="string">    -l 如遇到性质为符号连接的目录，直接列出该连接所指向的原始目录。</span></span><br><span class="line"><span class="string">    -n 不在文件和目录清单加上色彩。</span></span><br><span class="line"><span class="string">    -N 直接列出文件和目录名称，包括控制字符。</span></span><br><span class="line"><span class="string">    -p 列出权限标示。</span></span><br><span class="line"><span class="string">    -P 只显示符合范本样式的文件或目录名称。</span></span><br><span class="line"><span class="string">    -q 用&quot;?&quot;号取代控制字符，列出文件和目录名称。</span></span><br><span class="line"><span class="string">    -s 列出文件或目录大小。</span></span><br><span class="line"><span class="string">    -t 用文件和目录的更改时间排序。</span></span><br><span class="line"><span class="string">    -u 列出文件或目录的拥有者名称，没有对应的名称时，则显示用户识别码。</span></span><br><span class="line"><span class="string">    -x 将范围局限在现行的文件系统中，若指定目录下的某些子目录，其存放于另一个文件系统上，则将该子目录予以排除在寻找范围外。</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br></pre></td></tr></table></figure>

<h2 id="四、玉女心经之文件管理之中之创建-复制-移动-删除"><a href="#四、玉女心经之文件管理之中之创建-复制-移动-删除" class="headerlink" title="四、玉女心经之文件管理之中之创建/复制/移动/删除"></a>四、玉女心经之文件管理之中之创建/复制/移动/删除</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&#x27;&#x27;&#x27;创建&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="number">1.</span>touch  <span class="comment"># 创建文件</span></span><br><span class="line">	<span class="number">1.1</span> touch 相对路径</span><br><span class="line">    <span class="number">1.2</span> touch 绝对路径</span><br><span class="line">    <span class="number">1.3</span> touch /root/&#123;<span class="number">0.</span><span class="number">.9</span>&#125;.txt  <span class="comment"># 会创建0-9.txt，10个文件，字母也可以， ..的意思就是从哪到哪</span></span><br><span class="line"><span class="number">2.</span> mkdir  <span class="comment"># 创建文件夹(目录)</span></span><br><span class="line">	<span class="number">1.1</span> mkdir 相对路径</span><br><span class="line">    <span class="number">1.2</span> mkdir 绝对路径</span><br><span class="line">    <span class="number">1.3</span> mkdir /root/&#123;<span class="number">0.</span><span class="number">.9</span>&#125;.txt  <span class="comment"># ..同理创建文件</span></span><br><span class="line">    <span class="number">1.4</span> mkdir -v <span class="comment">#  mkdir -v /root/&#123;dir6,dir7&#125;</span></span><br><span class="line">                 <span class="comment">#  mkdir: 已创建目录 &quot;/root/dir6&quot;</span></span><br><span class="line">                 <span class="comment">#  mkdir: 已创建目录 &quot;/root/dir7&quot;</span></span><br><span class="line">	<span class="number">1.5</span> mkdir -p a/b/c  <span class="comment"># a b c三个文件夹不存在的都会创建</span></span><br><span class="line"><span class="number">3.</span> cp  <span class="comment"># 复制文件/文件夹</span></span><br><span class="line">    选项与参数：</span><br><span class="line">    -a：相当於 -pdr 的意思，至於 pdr 请参考下列说明；(常用)</span><br><span class="line">    -d：若来源档为连结档的属性(link file)，则复制连结档属性而非文件本身；</span><br><span class="line">    -f：为强制(force)的意思，若目标文件已经存在且无法开启，则移除后再尝试一次；</span><br><span class="line">    -i：若目标档(destination)已经存在时，在覆盖时会先询问动作的进行(常用)</span><br><span class="line">    -l：进行硬式连结(hard link)的连结档创建，而非复制文件本身；</span><br><span class="line">    -p：连同文件的属性一起复制过去，而非使用默认属性(备份常用)；</span><br><span class="line">    -r：递归持续复制，用于目录的复制行为；(常用)</span><br><span class="line">    -s：复制成为符号连结档 (symbolic link)，亦即『捷径』文件；</span><br><span class="line">    -u：若 destination 比 source 旧才升级 destination ！</span><br><span class="line">    -v：详细显示命令执行的操作</span><br><span class="line"><span class="number">4.</span> mv  <span class="comment"># 移动</span></span><br><span class="line">	mv 源 目标</span><br><span class="line">	mv file2 /home/dir3  <span class="comment"># 将file2移动到/home/dir3里</span></span><br><span class="line">	mv file4 file5  <span class="comment"># 将file4重命名为file5,当前位置里的移动就是重命名</span></span><br><span class="line"><span class="number">5.</span> rm  <span class="comment"># 删除</span></span><br><span class="line">	<span class="comment"># 示例：删除/home/dir1    </span></span><br><span class="line">    <span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">    cd /home</span></span><br><span class="line"><span class="string">    rm -rf dir1</span></span><br><span class="line"><span class="string">    &#x27;&#x27;&#x27;</span></span><br><span class="line">    -r  <span class="comment"># 递归</span></span><br><span class="line">    -f  <span class="comment"># force强制</span></span><br><span class="line">    -v  <span class="comment"># 详细过程</span></span><br></pre></td></tr></table></figure>

<h2 id="五、玉女心经之文件管理之中之查看文件"><a href="#五、玉女心经之文件管理之中之查看文件" class="headerlink" title="五、玉女心经之文件管理之中之查看文件"></a>五、玉女心经之文件管理之中之查看文件</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> cat <span class="comment"># 查看文件</span></span><br><span class="line">	<span class="number">1.1</span> cat -n  <span class="comment"># 显示行号</span></span><br><span class="line">    <span class="number">1.2</span> cat -A  <span class="comment"># 显示换行符之类的</span></span><br><span class="line"><span class="number">2.</span> less </span><br><span class="line"><span class="number">3.</span> more </span><br><span class="line">	<span class="number">3.1</span> more /etc/passwd  </span><br><span class="line">    <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    	使用more命令之后，每次在屏幕上显示一屏（一页）的文件内容，并且在屏幕的尾部将会出现“—More--（n%）”的信息，其中，n%是	已经显示文件内容的百分比。按空格下一页，按b上一页，more +40 a.txt从第40行开始查看</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br><span class="line"><span class="number">4.</span> head</span><br><span class="line">	<span class="number">4.1</span> head  /etc/passwd</span><br><span class="line">	<span class="number">4.2</span> head -<span class="number">2</span> /etc/passwd</span><br><span class="line"><span class="number">5.</span> tail</span><br><span class="line">	<span class="number">5.1</span> tail -f /var/log/messages  <span class="comment"># -f 动态查看文件的尾部</span></span><br><span class="line"><span class="number">6.</span> grep  <span class="comment"># 针对文件内容进行过滤搜索文件</span></span><br><span class="line">    grep <span class="string">&#x27;root&#x27;</span> /etc/passwd</span><br><span class="line">    grep --color <span class="string">&#x27;root&#x27;</span> /etc/passwd</span><br><span class="line">    grep --color <span class="string">&#x27;^root&#x27;</span> /etc/passwd</span><br><span class="line">    grep --color <span class="string">&#x27;bash$&#x27;</span> /etc/passwd</span><br></pre></td></tr></table></figure>

<h2 id="六、玉女心经之文件管理之中之修改文件"><a href="#六、玉女心经之文件管理之中之修改文件" class="headerlink" title="六、玉女心经之文件管理之中之修改文件"></a>六、玉女心经之文件管理之中之修改文件</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&quot;&quot;&quot;我们可以用vi或者vim来修改文件，如果没有vim，输入yum -y install vim下载&quot;&quot;&quot;</span></span><br><span class="line">我们得先懂vi操作模式</span><br><span class="line">输入模式&lt;-----a,i,o等键-------命令模式&lt;--------:键-----------末行模式</span><br><span class="line">末行模式&lt;-----esc-------------命令模式&lt;--------esc-----------输入模式</span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">1.命令行模式：在编辑模式下按下ESC键返回命令行模式。</span></span><br><span class="line"><span class="string">    vi的默认模式。在这一模式中，所有的输入被解释成vi命令，可以执行修改、复制、移动、粘贴和删除正文等命令，也可以进行移动光标、搜索字符串和退出vi的操作等。</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">2.编辑/插入模式：输入a、i、o之一</span></span><br><span class="line"><span class="string">在编辑模式中，可以往一个文件中输入正文。在这一模式下，输入的每一个字符都被vi编辑器解释为输入的正文。使用ESC键返回命令行模式。</span></span><br><span class="line"><span class="string">    a：进入插入模式并在光标之后进行添加。</span></span><br><span class="line"><span class="string">    i：进入插入模式并在光标之前进行插入。</span></span><br><span class="line"><span class="string">    o：进入插入模式并在当前（光标所在）行之下开启新的一行。</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">3.扩展/末行模式：输入冒号:</span></span><br><span class="line"><span class="string">	在一些UNIX系统上也叫最后一行模式。在这一模式下，可以使用一些高级编辑命令，如搜寻和替代字符串、存盘或退出vi编辑器等。要进入最后一行模式，需要在命令行模式中输入冒号（：），冒号这一操作将把光标移到屏幕的最后一行。</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="number">1.</span> VI编辑器的光标使用</span><br><span class="line">	<span class="number">1.1</span>	$  <span class="comment"># 光标移到当前行末尾</span></span><br><span class="line">	<span class="number">1.2</span> <span class="number">0</span>  <span class="comment"># 光标移到当前行的开始</span></span><br><span class="line"><span class="number">2.</span> 在命令行模式下删除与复制的操作</span><br><span class="line">	<span class="number">2.1</span> dd  <span class="comment"># 删除光标所在的一行</span></span><br><span class="line">    <span class="number">2.2</span> ndd  <span class="comment"># n为数字 删除光标所在的向下n行  比如10dd  就是删除光标所在的向下10行</span></span><br><span class="line">    <span class="number">2.3</span> yy  <span class="comment"># 复制光标所在的一行</span></span><br><span class="line">    <span class="number">2.4</span> nyy  <span class="comment"># n为数字 复制光标所在的向下n行</span></span><br><span class="line"><span class="number">3.</span> 粘贴命令</span><br><span class="line">	<span class="number">3.1</span> p  <span class="comment"># 粘贴到光标的下一行</span></span><br><span class="line">    <span class="number">3.2</span> P  <span class="comment"># 粘贴到光标的上一行</span></span><br><span class="line"><span class="number">4.</span> 复原和重做命令</span><br><span class="line">	<span class="number">4.1</span> U  <span class="comment"># 复原前一个操作</span></span><br><span class="line">    <span class="number">4.2</span> ctrl + r  <span class="comment"># 重做上一次操作</span></span><br><span class="line"><span class="number">5.</span> 掌握扩展模式下常用的命令</span><br><span class="line">	<span class="number">5.1</span> :w </span><br><span class="line">    <span class="number">5.2</span> :q</span><br><span class="line">    <span class="number">5.3</span> :wq	</span><br><span class="line"><span class="number">6.</span> 快速移动光标</span><br><span class="line">	<span class="number">6.1</span> G  <span class="comment"># 光标移动到这个文件的最后一行</span></span><br><span class="line">    <span class="number">6.2</span> nG  <span class="comment"># n为数字，光标移动到这个数字</span></span><br><span class="line">    <span class="number">6.3</span> gg  <span class="comment"># 移动到这个文件的第一行</span></span><br><span class="line">    <span class="number">6.4</span> H  <span class="comment"># 光标移动到这个屏幕的最上方的第一行行首</span></span><br><span class="line">    <span class="number">6.5</span> M  <span class="comment"># 光标移动到这个屏幕的最中间的第一行行首</span></span><br><span class="line">    <span class="number">6.6</span> L  <span class="comment"># 光标移动到这个屏幕的最下面的第一行行首</span></span><br></pre></td></tr></table></figure>

<h2 id="七、文件处理三剑客命令初探"><a href="#七、文件处理三剑客命令初探" class="headerlink" title="七、文件处理三剑客命令初探"></a>七、文件处理三剑客命令初探</h2><h3 id="7-1-sed"><a href="#7-1-sed" class="headerlink" title="7.1 sed"></a>7.1 sed</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">什么是sed？</span><br><span class="line"><span class="comment">#  sed-&gt;流式编辑器,主要擅长对文件的编辑操作，实现定制好编辑文件的指令，然后让sed自动完成对文件的整体编辑</span></span><br></pre></td></tr></table></figure>

<h4 id="7-1-1为何用-sed"><a href="#7-1-1为何用-sed" class="headerlink" title="7.1.1为何用 sed"></a>7.1.1为何用 sed</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sed vs vim</span><br><span class="line"><span class="number">1.</span>sed可以把处理文件的规则实现写好，然后同一套规则编辑多个文件，而vim只能一个个编辑==》用于一套规则处理多个文件</span><br><span class="line"><span class="number">2.</span>sed处理文件，一次只处理一行，即同以时间内存中只有文件的一行内容，无论文件多大，都不会对内存造成过大的压力===》用于处理大文件</span><br></pre></td></tr></table></figure>

<h4 id="7-1-2-如何用-sed"><a href="#7-1-2-如何用-sed" class="headerlink" title="7.1.2 如何用 sed"></a>7.1.2 如何用 sed</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">sed 选项 <span class="string">&#x27;定位+命令&#x27;</span>  文件路径</span><br><span class="line"></span><br><span class="line"><span class="comment">#选项</span></span><br><span class="line">-n  取消默认输出</span><br><span class="line">-i  把输出到屏幕中的内容（规则处理的结果+默认输出的结果）b</span><br><span class="line">-r 支持扩展正则元字符</span><br></pre></td></tr></table></figure>

<h4 id="7-1-3-sed-命令"><a href="#7-1-3-sed-命令" class="headerlink" title="7.1.3 sed  命令"></a>7.1.3 sed  命令</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">sed规则：定位+命令</span><br><span class="line">定位：行定位    正则定位</span><br><span class="line"><span class="comment"># 行定位：</span></span><br><span class="line"><span class="number">1</span> 定位到第一行，<span class="number">1</span>,<span class="number">3</span>代表从第一行到第三行</span><br><span class="line">不写定位代表定位所有行</span><br><span class="line"><span class="comment"># 正则表达式定位：</span></span><br><span class="line">/rock/ 包含rock的行</span><br><span class="line">/^rock/ 以rock开头的行</span><br><span class="line">/rock$/ 以rock结尾的行</span><br><span class="line"><span class="comment">#  数字+正则表达式定位：</span></span><br><span class="line"><span class="string">&#x27;1,9p&#x27;</span>代表打印<span class="number">1</span>到<span class="number">8</span>行</span><br><span class="line"><span class="string">&#x27;1,/rock/p&#x27;</span>代表从第一行到首次匹配到/rock/的行</span><br><span class="line">p  输出打印 <span class="string">&#x27;3p&#x27;</span></span><br><span class="line">d  删除   <span class="string">&#x27;2d&#x27;</span></span><br><span class="line">c  替换  <span class="string">&#x27;1c xxx&#x27;</span></span><br><span class="line">s///g  </span><br><span class="line"><span class="comment"># 命令可以用；号链接多条，如：1d；3d；5d代表删除1,3,5行  </span></span><br><span class="line"><span class="string">&#x27;1s/1/6/&#x27;</span>   第一行第一个<span class="number">1</span>改为<span class="number">6</span></span><br><span class="line"><span class="string">&#x27;1s/1/6/g&#x27;</span>  第一行所有<span class="number">1</span>改为<span class="number">6</span>  同<span class="string">&#x27;c&#x27;</span>一样</span><br><span class="line"><span class="string">&#x27;1s/1/6/gi&#x27;</span>   忽略大小写<span class="string">&#x27;i&#x27;</span></span><br></pre></td></tr></table></figure>



<h3 id="7-2-awk"><a href="#7-2-awk" class="headerlink" title="7.2 awk"></a>7.2 awk</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#  格式化输出，处理有格式的文本，例如：/etc/passwd这种</span></span><br><span class="line"><span class="comment">#  用法</span></span><br><span class="line">awk 选项 <span class="string">&#x27;pattern&#123;action&#125;&#x27;</span>  文件路径</span><br><span class="line"><span class="comment"># 选项：</span></span><br><span class="line"><span class="string">&#x27;-F:&#x27;</span>  指定分隔符</span><br><span class="line"><span class="comment">#  工作流程</span></span><br><span class="line">awk -F: <span class="string">&#x27;&#123;print $1,$3&#125;&#x27;</span> /etc/passwd 或：</span><br><span class="line">   awk -F： <span class="string">&#x27;NR&gt;=1 &amp;&amp; NR&lt;=3&#123;print $1,$3&#125;&#x27;</span> /etc/passwd</span><br><span class="line"><span class="comment">#  定位： 行定位    正则定位</span></span><br><span class="line">NR  记录号，等同于行号</span><br><span class="line">-F  指定分隔符号指令</span><br><span class="line">$   指定列</span><br><span class="line">NF + $ NF ($NF-<span class="number">1</span>) NF末尾列</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="7-3-grep"><a href="#7-3-grep" class="headerlink" title="7.3 grep"></a>7.3 grep</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 擅长过滤内容</span></span><br><span class="line">grep <span class="string">&#x27;root&#x27;</span>  检索所有包含的</span><br><span class="line">grep -n <span class="string">&#x27;root&#x27;</span>检索所有包含并且有行号</span><br><span class="line">grep -i <span class="string">&#x27;root&#x27;</span>检索所有包含并且不区分大小写</span><br><span class="line">grep -rl <span class="string">&#x27;root&#x27;</span> /etc/passwd</span><br><span class="line">ps aux | grep bash</span><br><span class="line"></span><br><span class="line">示例：</span><br><span class="line">grep <span class="string">&#x27;^root$&#x27;</span> /etc/passwd</span><br><span class="line">^代表首部包含，$代表尾部包含</span><br></pre></td></tr></table></figure>

<h2 id="八-文件查找"><a href="#八-文件查找" class="headerlink" title="八. 文件查找"></a>八. 文件查找</h2><h3 id="8-1-查看命令所属文件"><a href="#8-1-查看命令所属文件" class="headerlink" title="8.1 查看命令所属文件"></a>8.1 查看命令所属文件</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#  which ip  查看命令所属文件夹</span></span><br><span class="line">which [command]</span><br></pre></td></tr></table></figure>

<h3 id="8-2-查找文件"><a href="#8-2-查找文件" class="headerlink" title="8.2 查找文件"></a>8.2 查找文件</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">find [options] [path] .. [expression]</span><br><span class="line"><span class="comment"># 参数：</span></span><br><span class="line">-a   并且</span><br><span class="line">-o   或者</span><br></pre></td></tr></table></figure>

<h4 id="8-21-按文件名查找："><a href="#8-21-按文件名查找：" class="headerlink" title="8.21 按文件名查找："></a>8.21 按文件名查找：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">find [路径] -name <span class="string">&#x27;[匹配规则]&#x27;</span></span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg -eth0&#x27;</span></span><br><span class="line">find /etc -iname <span class="string">&#x27;ifcdf-eth0&#x27;</span> <span class="comment"># -i 忽略大小写</span></span><br><span class="line">find /etc -iname <span class="string">&#x27;ifcfg-eth0*&#x27;</span> <span class="comment"># * 后面随便是什么</span></span><br><span class="line">find /etc -name <span class="string">&#x27;*pass*&#x27;</span>  文件名称中包含<span class="keyword">pass</span>的文件，不管开头还是结尾</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="8-22-按文件大小查找："><a href="#8-22-按文件大小查找：" class="headerlink" title="8.22 按文件大小查找："></a>8.22 按文件大小查找：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">find /etc -size +3M  <span class="comment"># 大于3M</span></span><br><span class="line">find /etc -size 3M   <span class="comment"># =3M</span></span><br><span class="line">find /etc -size -3M  <span class="comment"># 小于3M</span></span><br><span class="line">find /etc -size +3M -ls  <span class="comment"># -ls 找到后的处理动作</span></span><br><span class="line">find /etc -size +30M -size -50M</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="8-23-指定查找的目录深度："><a href="#8-23-指定查找的目录深度：" class="headerlink" title="8.23 指定查找的目录深度："></a>8.23 指定查找的目录深度：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -maxdepth levels   不能单独使用</span></span><br><span class="line">find / -maxdepth <span class="number">5</span> -a -name <span class="string">&#x27;ifcfg-eth0&#x27;</span></span><br><span class="line"><span class="comment"># -a 并且， -o 或者 。不加-a代表默认</span></span><br></pre></td></tr></table></figure>

<h4 id="8-24-按时间找："><a href="#8-24-按时间找：" class="headerlink" title="8.24 按时间找："></a>8.24 按时间找：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#参数：</span></span><br><span class="line">-ctime：创建时间</span><br><span class="line">-atime：访问时间</span><br><span class="line">-mtime：修改时间</span><br><span class="line">find /etc -mtime +<span class="number">3</span>    <span class="comment">#修改时间超过3天</span></span><br><span class="line">find /etc -mtime  <span class="number">3</span>	   <span class="comment">#修改时间等于3天</span></span><br><span class="line">find /etc -mtime -<span class="number">3</span>    <span class="comment">#修改时间3天以内</span></span><br></pre></td></tr></table></figure>

<h4 id="8-25-按文件属主、属组找："><a href="#8-25-按文件属主、属组找：" class="headerlink" title="8.25 按文件属主、属组找："></a>8.25 按文件属主、属组找：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">格式：</span><br><span class="line">find [路径] [匹配类型]</span><br><span class="line">find /home -user rock    <span class="comment">#属主是rick的文件</span></span><br><span class="line">find /home -group it     <span class="comment">#属组是it组的文件</span></span><br><span class="line">find /home -user rock -goup it </span><br><span class="line">find /home -user rock -a -group it </span><br><span class="line"><span class="comment"># 属主rock 并且属组it</span></span><br><span class="line">find /home -nouser <span class="comment">#用户还存在，在/etc/passwd删除了记录</span></span><br><span class="line">find /home -nogroup <span class="comment">#用户还存在，在/etc/group中删除了记录</span></span><br><span class="line">find /home -nouser -o nogroup </span><br></pre></td></tr></table></figure>

<h4 id="8-26-按文件类型查找："><a href="#8-26-按文件类型查找：" class="headerlink" title="8.26 按文件类型查找："></a>8.26 按文件类型查找：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">格式：</span><br><span class="line">find [路径] [匹配类型] </span><br><span class="line">find /root -<span class="built_in">type</span> f  <span class="comment">#f 普通文件</span></span><br><span class="line">find /dev -<span class="built_in">type</span> d   <span class="comment">#d 目录</span></span><br><span class="line">find /dev -<span class="built_in">type</span> l   <span class="comment">#l 链接</span></span><br><span class="line">find /dev -<span class="built_in">type</span> b	<span class="comment">#b 块设备</span></span><br><span class="line">find /dev -<span class="built_in">type</span> c	<span class="comment">#c 字符设备</span></span><br><span class="line">find /dev -typr s	<span class="comment">#s 套接字</span></span><br><span class="line">find /dev -<span class="built_in">type</span> p	<span class="comment">#p 管道文件</span></span><br></pre></td></tr></table></figure>

<h4 id="8-27-根据inode号查找：-inum-n"><a href="#8-27-根据inode号查找：-inum-n" class="headerlink" title="8.27 根据inode号查找： -inum   n"></a>8.27 根据inode号查找： -inum   n</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find / -inum <span class="number">1811</span></span><br></pre></td></tr></table></figure>

<h4 id="8-28-按文件权限查找："><a href="#8-28-按文件权限查找：" class="headerlink" title="8.28 按文件权限查找："></a>8.28 按文件权限查找：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">格式：</span><br><span class="line">find [路径] -perm [可执行权限]</span><br><span class="line">find . -perm <span class="number">644</span> -ls</span><br><span class="line">find . -perm -<span class="number">644</span> -ls</span><br><span class="line">fing . -perm -<span class="number">600</span> -ls</span><br><span class="line">find /sbin -perm -<span class="number">4000</span> -ls <span class="comment">#包含set UID</span></span><br><span class="line">find /sbin -perm -<span class="number">2000</span> -ls <span class="comment">#包含set GID</span></span><br><span class="line">find /sbin -perm -<span class="number">1000</span> -ls <span class="comment">#包含sticky</span></span><br></pre></td></tr></table></figure>

<h4 id="8-29-找到后处理的动作："><a href="#8-29-找到后处理的动作：" class="headerlink" title="8.29 找到后处理的动作："></a>8.29 找到后处理的动作：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">-<span class="built_in">print</span></span><br><span class="line">-ls</span><br><span class="line">-delete</span><br><span class="line">-<span class="built_in">exec</span></span><br><span class="line">是find终端参数之一，将find查询出来的内容交给其他命令来处理</span><br><span class="line">-ok</span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg*&#x27;</span> -<span class="built_in">print</span> </span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg*&#x27;</span> -ls</span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg*&#x27;</span> <span class="built_in">exec</span> cp -rvf &#123;&#125; /tmp \;  <span class="comment">#非交互</span></span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg*&#x27;</span> -ok cp -rvf &#123;&#125; /tmp \;</span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg&#x27;</span> -<span class="built_in">exec</span> rm -rf &#123;&#125;\;</span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg*&#x27;</span> -<span class="built_in">exec</span> rm -rf &#123;&#125;\;</span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg*&#x27;</span> -delete </span><br></pre></td></tr></table></figure>

<h4 id="扩展知识：-find结合xargs："><a href="#扩展知识：-find结合xargs：" class="headerlink" title="扩展知识： find结合xargs："></a>扩展知识： find结合xargs：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-I  赋值的意思</span><br><span class="line">find . -name <span class="string">&#x27;egon*.txt&#x27;</span> | xargs rm -rf</span><br><span class="line">find /etc -name <span class="string">&#x27;ifcfg-eth0&#x27;</span> |xargs -I &#123;&#125; cp -rf &#123;&#125; /var/tmp</span><br><span class="line">find /test -name <span class="string">&#x27;ifcfg-ens33&#x27;</span> | xargs -I &#123;&#125; mv &#123;&#125; /ttt</span><br><span class="line">find /ttt/ -name <span class="string">&#x27;ifcfg*&#x27;</span> |xargs -I &#123;&#125; chmod <span class="number">666</span> &#123;&#125;</span><br></pre></td></tr></table></figure>

<h4 id="作业："><a href="#作业：" class="headerlink" title="作业："></a>作业：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> 查找 ifconfig命令文件的位置，。用不同的方式实现</span><br><span class="line"><span class="number">2.</span>查找/etc/中的所有子目录（仅目录）复制到/tmp下</span><br><span class="line"><span class="number">3.</span>查找/etc目录复制到/var/tmp/，将var/tmp/etc中的所有目录设置权限<span class="number">777</span>（仅目录）将/var/tmp/etc中所有文件权限设置为<span class="number">666</span></span><br></pre></td></tr></table></figure>



<h2 id="九-文件的上传下载"><a href="#九-文件的上传下载" class="headerlink" title="九.文件的上传下载"></a>九.文件的上传下载</h2><h3 id="9-1-下载"><a href="#9-1-下载" class="headerlink" title="9.1 下载"></a>9.1 下载</h3><h4 id="9-11-wget命令"><a href="#9-11-wget命令" class="headerlink" title="9.11 wget命令"></a>9.11 wget命令</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">wget -o 本地路径 远程包链接地址 <span class="comment"># 将远程报下载到本地，-o指定下载到哪里，可以省略 -0 本地路径，下载到当前文件夹</span></span><br><span class="line"></span><br><span class="line">ps: 如果wget下载提示无法建立ssl链接，则加上选项 --no-check-certificate</span><br><span class="line">wget --no-check0certificate -o 本地路径 远程包链接地址</span><br></pre></td></tr></table></figure>

<h4 id="9-12-curl命令"><a href="#9-12-curl命令" class="headerlink" title="9.12 curl命令"></a>9.12 curl命令</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#curl命令是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载，所以是综合传输工具，但按传统，习惯成curl为下载工具。作为一款强力工具，curl支持包括HTTP、HTTPS、[ftp]等众多协议，还支持POST、cookies、认证、从指定偏移处下载部分文件、用户代理字符串、限速、文件大小、进度条等特征。做网页处理流程和数据检索自动化，curl可以助一臂之力</span></span><br><span class="line"></span><br><span class="line">curl -o <span class="number">123.</span>png https://www.xxx.com/img/hello.png</span><br><span class="line">ps:如果遇到下载提示无法建立ssl链接，使用-k选项或者--insecure</span><br><span class="line">curl -k -o <span class="number">123.</span>png https://www.xxx.com/img/hello.png</span><br></pre></td></tr></table></figure>

<h4 id="9-13-sz-命令"><a href="#9-13-sz-命令" class="headerlink" title="9.13 sz 命令"></a>9.13 sz 命令</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">系统默认没有该命令，需要下载 ：yum install lrzdz -y</span><br><span class="line"><span class="comment">#将服务器上选定的文件下载/发送到本机</span></span><br><span class="line">sz bal.tar.gz</span><br></pre></td></tr></table></figure>

<h3 id="9-2-上传"><a href="#9-2-上传" class="headerlink" title="9.2 上传"></a>9.2 上传</h3><h4 id="9-21-r-z命令"><a href="#9-21-r-z命令" class="headerlink" title="9.21 r z命令"></a>9.21 r z命令</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">系统默认没有该命令，需要下载： yum install lrzsz -y </span><br><span class="line">运行该命令会弹出一个文件选择窗口，从本地选择文件上传到服务器</span><br><span class="line">rz /etc/passwd  <span class="comment">#如果文件已经存在，则上传失败，可以用-E选项解决</span></span><br><span class="line">rz -E /etc/passwd  <span class="comment">#-E 如果目标文件名已经存在，则重命名传入文件。新文件名将添加一个点和一个数字</span></span><br></pre></td></tr></table></figure>

<h2 id="十-输出与重定向"><a href="#十-输出与重定向" class="headerlink" title="十.输出与重定向"></a>十.输出与重定向</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">输出即把相关对象通过输出设备（显示器等）显示出来，输出又分为正确输出和错误输出，一般情况下标准输出设备为显示器，标准输入设备为键盘</span><br><span class="line">Linux中用：</span><br><span class="line"><span class="number">0</span>代表标准输入</span><br><span class="line"><span class="number">1</span>代表标准正确输出</span><br><span class="line"><span class="number">2</span>代表标准错误输出</span><br><span class="line"><span class="comment">#############001图片</span></span><br></pre></td></tr></table></figure>

<h3 id="10-1-输出重定向："><a href="#10-1-输出重定向：" class="headerlink" title="10.1 输出重定向："></a>10.1 输出重定向：</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">正常输出是把内容输出到显示器上，而输出重定向是吧内容输出到文件中，&gt;代表覆盖，&gt;&gt;代表追加</span><br><span class="line">ps：标准输出的<span class="number">1</span>可以省略</span><br><span class="line"><span class="comment"># 标准输出重定向：</span></span><br><span class="line">命令 &gt; 文件 以覆盖的方式，把命令的正确输出，输出到指定的文件或设备当中</span><br><span class="line">命令 &gt;&gt; 文件 以追加的方式，把命令的正确输出，输出到指定的文件或设备当中</span><br><span class="line">0002图片</span><br><span class="line"><span class="comment"># 标准错误输出重定向：</span></span><br><span class="line">错误命令 <span class="number">2</span>&gt;文件	以覆盖的方式把命令的错误输出，输出到指定的文件或设备当中</span><br><span class="line">错误命令 <span class="number">2</span>&gt;&gt;文件 以追加的方式把命令的错误输出，输出到指定的文件或设备当中</span><br><span class="line">0003图片</span><br><span class="line"><span class="comment"># 注意：错误输出重定向&gt;与&gt;&gt;后边不要加空格</span></span><br><span class="line">例如：ifconfig &gt; test.log即把ifconfig执行显示的正确内容写入test.log，当前页面不再显示执行结果</span><br><span class="line"></span><br><span class="line"><span class="comment">#注意： </span></span><br><span class="line"><span class="number">1.</span>下属两个命令作用相同</span><br><span class="line">命令 &gt;&gt;file.log <span class="number">2</span>&gt;&amp;<span class="number">1</span></span><br><span class="line">命令 &amp;&gt;&gt;file.log</span><br><span class="line"><span class="number">2.</span>正确日志和错误日志分开保存</span><br><span class="line">命令 &gt;&gt;file1.log <span class="number">2</span>&gt;&gt;file2.log</span><br><span class="line"><span class="number">3.</span>系统有个常见永华 ls &amp;&gt;/dev/null 正确输出或错误输出结果都不要</span><br></pre></td></tr></table></figure>

<h3 id="10-2-输入重定向"><a href="#10-2-输入重定向" class="headerlink" title="10.2 输入重定向"></a>10.2 输入重定向</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">tr <span class="string">&#x27;N&#x27;</span> <span class="string">&#x27;n&#x27;</span>  命令输入： NO  转变为： no</span><br><span class="line">tr <span class="string">&#x27;rock&#x27;</span> <span class="string">&#x27;ROCK&#x27;</span> &lt; a1.txt 改变文件内容输出</span><br><span class="line">grep <span class="string">&#x27;root&#x27;</span>  命令输入查找</span><br><span class="line">grep <span class="string">&#x27;root&#x27;</span> &lt; /etc/passwd  文件内容查找</span><br><span class="line"></span><br><span class="line">读写块设备</span><br><span class="line">dd <span class="keyword">if</span>=/dev/zero of=/file1.txt bs=1M count=<span class="number">20</span></span><br><span class="line">dd &lt;/dev/zero &gt;/file2.txt bs=1M count=<span class="number">20</span></span><br><span class="line"></span><br><span class="line">musql如何恢复备份，了解即可</span><br><span class="line">mysql -uroot -p123 &lt; bbs.sql</span><br></pre></td></tr></table></figure>



<h1 id="十一-字符处理命令"><a href="#十一-字符处理命令" class="headerlink" title="十一.字符处理命令"></a>十一.字符处理命令</h1><h3 id="11-1-sort命令"><a href="#11-1-sort命令" class="headerlink" title="11.1 sort命令"></a>11.1 sort命令</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">用于将文件内容加以排序</span><br><span class="line">-n 依照数值的大小排序</span><br><span class="line">-r 以相反的顺序来排序</span><br><span class="line">-k 以列进行排序</span><br><span class="line">-t 指定分隔符，默认是空格为分隔符</span><br></pre></td></tr></table></figure>

<h4 id="例题："><a href="#例题：" class="headerlink" title="例题："></a>例题：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">cat &gt;&gt; file.txt &lt;&lt; EOF</span><br><span class="line">b:<span class="number">2</span></span><br><span class="line">c:<span class="number">2</span></span><br><span class="line">a:<span class="number">4</span></span><br><span class="line">e:<span class="number">5</span></span><br><span class="line">d:<span class="number">1</span></span><br><span class="line">f:<span class="number">11</span></span><br></pre></td></tr></table></figure>

<h4 id="例题1"><a href="#例题1" class="headerlink" title="例题1"></a>例题1</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">sort file.txt</span><br><span class="line">a:<span class="number">4</span></span><br><span class="line">b:<span class="number">3</span></span><br><span class="line">c:<span class="number">2</span></span><br><span class="line">d:<span class="number">1</span></span><br><span class="line">e:<span class="number">5</span></span><br><span class="line">f:<span class="number">11</span></span><br></pre></td></tr></table></figure>

<h4 id="例题2"><a href="#例题2" class="headerlink" title="例题2"></a>例题2</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">sort -t <span class="string">&#x27;:&#x27;</span> -n -k2 file.txt</span><br><span class="line">d:<span class="number">1</span></span><br><span class="line">c:<span class="number">2</span></span><br><span class="line">b:<span class="number">3</span></span><br><span class="line">a:<span class="number">4</span></span><br><span class="line">e:<span class="number">5</span></span><br><span class="line">f:<span class="number">11</span></span><br></pre></td></tr></table></figure>

<h4 id="例题3"><a href="#例题3" class="headerlink" title="例题3"></a>例题3</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">sort -t <span class="string">&#x27;:&#x27;</span> -n -r -k2 file.txt</span><br><span class="line">f:<span class="number">11</span></span><br><span class="line">e:<span class="number">5</span></span><br><span class="line">a:<span class="number">4</span></span><br><span class="line">b:<span class="number">3</span></span><br><span class="line">c:<span class="number">2</span></span><br><span class="line">d:<span class="number">1</span></span><br></pre></td></tr></table></figure>

<h3 id="11-2-uniq命令"><a href="#11-2-uniq命令" class="headerlink" title="11.2 uniq命令"></a>11.2 uniq命令</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 用于检查即删除文本文件中重复出现的行列，一般与sort命令结合使用</span></span><br><span class="line">-c 在每列旁边显示改行重复出现的次数</span><br><span class="line">-d 仅显示重复出现的行列</span><br><span class="line">-u 仅显示出一次的行列</span><br></pre></td></tr></table></figure>

<h4 id="准备文件，写入一段无序的内容："><a href="#准备文件，写入一段无序的内容：" class="headerlink" title="准备文件，写入一段无序的内容："></a>准备文件，写入一段无序的内容：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">cat &gt;&gt; file1.txt &lt;&lt; EOF</span><br><span class="line">hello</span><br><span class="line"><span class="number">123</span></span><br><span class="line">hello</span><br><span class="line"><span class="number">123</span></span><br><span class="line">func</span><br><span class="line">EOF</span><br></pre></td></tr></table></figure>

<h4 id="例题1-1"><a href="#例题1-1" class="headerlink" title="例题1"></a>例题1</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">sort file1.txt | uniq</span><br><span class="line"><span class="number">123</span></span><br><span class="line">func</span><br><span class="line">hello</span><br></pre></td></tr></table></figure>

<h4 id="例题2-1"><a href="#例题2-1" class="headerlink" title="例题2"></a>例题2</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">sort file1.txt | uniq -c</span><br><span class="line"><span class="number">2</span> <span class="number">123</span></span><br><span class="line"><span class="number">1</span> func</span><br><span class="line"><span class="number">2</span> hello</span><br></pre></td></tr></table></figure>

<h4 id="例题3-1"><a href="#例题3-1" class="headerlink" title="例题3"></a>例题3</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sort file1.txt | uniq -d</span><br><span class="line"><span class="number">123</span></span><br><span class="line">hello</span><br></pre></td></tr></table></figure>

<h3 id="5-3-cut命令"><a href="#5-3-cut命令" class="headerlink" title="5.3 cut命令"></a>5.3 cut命令</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">cut命令用来显示行中的指定部分，删除文件中指定字段</span><br><span class="line">-d 指定字段的分隔符，默认的字段分隔符为<span class="string">&#x27;TAB&#x27;</span></span><br><span class="line">-f 显示指定字段的内容</span><br><span class="line">例如：</span><br><span class="line">head -1 /etc/passwd | cut -d <span class="string">&#x27;:&#x27;</span> -f1,3,4,6</span><br></pre></td></tr></table></figure>

<h2 id="5-4-tr命令"><a href="#5-4-tr命令" class="headerlink" title="5.4 tr命令"></a>5.4 tr命令</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">替换或者删除命令</span><br><span class="line">-d 删除字节</span><br><span class="line">tr <span class="string">&#x27;N&#x27;</span> <span class="string">&#x27;n&#x27;</span>  命令输入： NO  转变为： no</span><br><span class="line">tr <span class="string">&#x27;rock&#x27;</span> <span class="string">&#x27;ROCK&#x27;</span> &lt; a1.txt 改变文件内容输出</span><br></pre></td></tr></table></figure>

<h3 id="例题1-2"><a href="#例题1-2" class="headerlink" title="例题1"></a>例题1</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">head -<span class="number">1</span> /etc/passwd | tr <span class="string">&#x27;root&#x27;</span> <span class="string">&#x27;ROOT&#x27;</span></span><br><span class="line">   ROOT:x:<span class="number">0</span>:<span class="number">0</span>:ROOT:/ROOT:/<span class="built_in">bin</span>/bash</span><br><span class="line">head -<span class="number">1</span> /etc/passwd |tr -d <span class="string">&#x27;root&#x27;</span></span><br><span class="line">   :x:<span class="number">0</span>:<span class="number">0</span>::/:/<span class="built_in">bin</span>/bash</span><br></pre></td></tr></table></figure>

<h3 id="例题2-2"><a href="#例题2-2" class="headerlink" title="例题2"></a>例题2</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">echo <span class="string">&#x27;hello rock qq:411946773&#x27;</span> &gt; a1.txt</span><br><span class="line">tr <span class="string">&#x27;egon&#x27;</span> <span class="string">&#x27;egon&#x27;</span> &lt; a1.txt</span><br><span class="line">hEllO EGON</span><br><span class="line">会替换所有包含的字母</span><br></pre></td></tr></table></figure>

<h2 id="5-5-wc命令"><a href="#5-5-wc命令" class="headerlink" title="5.5 wc命令"></a>5.5 wc命令</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">统计，计算数字</span><br><span class="line">-c 统计文件的Bytes数；</span><br><span class="line">-l 统计文件的行数</span><br><span class="line">-w 统计文件中单词的个数，默认以空白字符作为分割符</span><br></pre></td></tr></table></figure>

<h3 id="例题1-3"><a href="#例题1-3" class="headerlink" title="例题1"></a>例题1</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ll file.txt</span><br><span class="line">wc -c file.txt</span><br><span class="line"><span class="number">25</span> file.txt</span><br></pre></td></tr></table></figure>

<h3 id="例题2-3"><a href="#例题2-3" class="headerlink" title="例题2"></a>例题2</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">cat file.txt</span><br><span class="line">hello</span><br><span class="line"><span class="number">123</span></span><br><span class="line">hello</span><br><span class="line"><span class="number">123</span></span><br><span class="line">func</span><br><span class="line">wc -l file.txt</span><br><span class="line"><span class="number">5</span> file.txt</span><br><span class="line">grep <span class="string">&#x27;hello&#x27;</span> file.txt |wc -l</span><br><span class="line"><span class="number">2</span></span><br></pre></td></tr></table></figure>

<h3 id="例题3-2"><a href="#例题3-2" class="headerlink" title="例题3"></a>例题3</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">cat file.txt</span><br><span class="line">hello</span><br><span class="line"><span class="number">123</span></span><br><span class="line">hello</span><br><span class="line"><span class="number">123</span></span><br><span class="line">func</span><br><span class="line">wc -w file.txt</span><br><span class="line"><span class="number">5</span> file.txt</span><br></pre></td></tr></table></figure>

<h1 id="6-打包压缩"><a href="#6-打包压缩" class="headerlink" title="6.打包压缩"></a>6.打包压缩</h1><h2 id="6-1-什么是打包压缩"><a href="#6-1-什么是打包压缩" class="headerlink" title="6.1 什么是打包压缩"></a>6.1 什么是打包压缩</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">打包指的是将多个文件和目录合并为一个特殊文件</span><br><span class="line">然后将特殊文件进行压缩</span><br><span class="line">最终得到一个压缩包</span><br></pre></td></tr></table></figure>

<h2 id="6-2为什么使用压缩包"><a href="#6-2为什么使用压缩包" class="headerlink" title="6.2为什么使用压缩包"></a>6.2为什么使用压缩包</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>减少占用的体积</span><br><span class="line"><span class="number">2.</span>加快网络的传输</span><br></pre></td></tr></table></figure>

<h2 id="6-3Windoes的压缩和Linux的有什么不同？"><a href="#6-3Windoes的压缩和Linux的有什么不同？" class="headerlink" title="6.3Windoes的压缩和Linux的有什么不同？"></a>6.3Windoes的压缩和Linux的有什么不同？</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Windows ： <span class="built_in">zip</span> 、rar(linux不支持)</span><br><span class="line">Linux ：<span class="built_in">zip</span>、tar、gz tar、bz2、gz</span><br><span class="line">如果希望windows和linux互通，选择<span class="built_in">zip</span></span><br><span class="line">ps：压缩包的后缀不重要，但一定要加上</span><br></pre></td></tr></table></figure>

<h2 id="6-4打包压缩方法"><a href="#6-4打包压缩方法" class="headerlink" title="6.4打包压缩方法"></a>6.4打包压缩方法</h2><h3 id="6-4-1-打包"><a href="#6-4-1-打包" class="headerlink" title="6.4.1 打包"></a>6.4.1 打包</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">tar cvf etc_bak.tar /etc/</span><br><span class="line">tar cvpf etc_bak,tar  不提示删除 <span class="string">&#x27;/&#x27;</span></span><br><span class="line">-f:指定打包的文件名称</span><br><span class="line">-c:打包文件</span><br><span class="line">-v：显示打包的过程</span><br><span class="line">-z：使用gzip压缩算法进行压缩处理</span><br><span class="line">-j使用bzip2压缩算法进行压缩处理</span><br><span class="line">-p：在打包过程中，取消移除根目录说明</span><br><span class="line">-x：将tar打包的压缩报解压</span><br><span class="line">-t：查看压缩包内的内容</span><br><span class="line">-c：解压至指定目录</span><br></pre></td></tr></table></figure>

<h3 id="6-4-2-压缩"><a href="#6-4-2-压缩" class="headerlink" title="6.4.2 压缩"></a>6.4.2 压缩</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">gzip etc_bak.tar  文件体积边下，并且加上后缀.gz</span><br><span class="line"></span><br><span class="line">解压为：</span><br><span class="line">gzip -&gt; gunzip</span><br><span class="line">bzip2 -&gt; bunzip</span><br></pre></td></tr></table></figure>

<h3 id="6-4-3-打包压缩一起"><a href="#6-4-3-打包压缩一起" class="headerlink" title="6.4.3 打包压缩一起"></a>6.4.3 打包压缩一起</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">tar czvf etc1_bak.tar.gz /etc </span><br><span class="line">选项z代表gzip的压缩算法</span><br><span class="line">tar cjvf etc1.bak.tar.bz2 /etc/</span><br><span class="line">选项j代表bzip2的压缩算法</span><br></pre></td></tr></table></figure>

<h2 id="6-5-1-打包压缩方法二"><a href="#6-5-1-打包压缩方法二" class="headerlink" title="6.5.1 打包压缩方法二"></a>6.5.1 打包压缩方法二</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">选项  -r 递归压缩，压缩目录</span><br><span class="line">选项  -q 静默输出</span><br><span class="line"><span class="built_in">zip</span> /test/bak.<span class="built_in">zip</span> a.txt b.txt c.txt</span><br><span class="line"><span class="comment">#zip后的第一个参数是压缩包路径，其余为被压缩的文件</span></span><br><span class="line">ls /test/      </span><br><span class="line">bak.<span class="built_in">zip</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">zip</span> -rq etc.<span class="built_in">zip</span> /etc</span><br><span class="line"><span class="comment"># 加上-q后压缩过程不再提示</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="6-6-解压缩"><a href="#6-6-解压缩" class="headerlink" title="6.6 解压缩"></a>6.6 解压缩</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">针对xxx.tar.gz 或者xxx.tar.bz2 统一使用</span><br><span class="line">tar xvf 压缩包 -c 解压到的目录  </span><br><span class="line"><span class="comment"># 无需指定解压算法，tar会自动判断</span></span><br><span class="line">针对 xxx.<span class="built_in">zip</span> 用unzip</span><br><span class="line">选项：</span><br><span class="line">-l 显示压缩包的列表信息</span><br><span class="line">-q 静默输出</span><br><span class="line">-d 解压到指定的目录</span><br><span class="line">unzip -<span class="number">1</span> xxx.<span class="built_in">zip</span> -d /opt</span><br></pre></td></tr></table></figure>

<h2 id="6-7-拓展"><a href="#6-7-拓展" class="headerlink" title="6.7 拓展"></a>6.7 拓展</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">打包压缩通常用于备份文件，文件的名字必须见名知意切应该带上时间、主机名之类</span><br></pre></td></tr></table></figure>

<h3 id="时间命令date"><a href="#时间命令date" class="headerlink" title="时间命令date"></a>时间命令date</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">选项：</span><br><span class="line">-d	根据你的描述显示日期</span><br><span class="line">-s	修改日期</span><br><span class="line">%H	小时，<span class="number">24</span>小时制</span><br><span class="line">%M	分钟</span><br><span class="line">%s	从<span class="number">1970</span>年<span class="number">1</span>月<span class="number">1</span>日<span class="number">0</span>点到目前经历的秒数</span><br><span class="line">%S	显示秒</span><br><span class="line">%T	显示时间 <span class="number">24</span>小时制</span><br><span class="line">%d	一个月的第几天</span><br><span class="line">%j	一年的第几天</span><br><span class="line">%m	月份</span><br><span class="line">%w	一个星期的第几天</span><br><span class="line">%W	一年的第几个星期</span><br><span class="line">%y	年的最后两个数字</span><br><span class="line">%Y	年，实际</span><br><span class="line">%F	显示日期</span><br></pre></td></tr></table></figure>

<h3 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost ~]<span class="comment"># date</span></span><br><span class="line"><span class="number">2020</span>年 08月 <span class="number">12</span>日 星期三 <span class="number">20</span>:<span class="number">55</span>:<span class="number">48</span> CST</span><br><span class="line">[root@localhost ~]<span class="comment"># date +%F</span></span><br><span class="line"><span class="number">2020</span>-08-<span class="number">12</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%Y-%m-%d</span></span><br><span class="line"><span class="number">2020</span>-08-<span class="number">12</span></span><br><span class="line">[root@localhost ~]<span class="comment"># </span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%y-%m-%d</span></span><br><span class="line"><span class="number">20</span>-08-<span class="number">12</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%T</span></span><br><span class="line"><span class="number">00</span>:01:03</span><br><span class="line">[root@localhost ~]<span class="comment"># date +%H:%M:%S</span></span><br><span class="line"><span class="number">00</span>:01:<span class="number">11</span></span><br><span class="line">[root@localhost ~]<span class="comment"># </span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%w</span></span><br><span class="line"><span class="number">3</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%s</span></span><br><span class="line"><span class="number">1597236988</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%d</span></span><br><span class="line"><span class="number">12</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%W</span></span><br><span class="line"><span class="number">32</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%j</span></span><br><span class="line"><span class="number">225</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date -d &quot;-1 day&quot; +%F</span></span><br><span class="line"><span class="number">2020</span>-08-<span class="number">11</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date -d &quot;1 day&quot; +%F</span></span><br><span class="line"><span class="number">2020</span>-08-<span class="number">13</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date -d &quot;+1 day&quot; +%F</span></span><br><span class="line"><span class="number">2020</span>-08-<span class="number">13</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date -d &quot;3 years&quot; +%F</span></span><br><span class="line"><span class="number">2023</span>-08-<span class="number">12</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date -d &quot;+3 years&quot; +%F</span></span><br><span class="line"><span class="number">2023</span>-08-<span class="number">12</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date -d &quot;+3 hours&quot; +%F_%H:%M:%S</span></span><br><span class="line"><span class="number">2020</span>-08-<span class="number">12_23</span>:<span class="number">58</span>:06</span><br><span class="line">​</span><br><span class="line">[root@localhost ~]<span class="comment"># date -s 20201111</span></span><br><span class="line"><span class="number">2020</span>年 <span class="number">11</span>月 <span class="number">11</span>日 星期三 <span class="number">00</span>:<span class="number">00</span>:<span class="number">00</span> CST</span><br><span class="line">[root@localhost ~]<span class="comment"># date -s 11:11:11</span></span><br><span class="line"><span class="number">2020</span>年 <span class="number">11</span>月 <span class="number">11</span>日 星期三 <span class="number">11</span>:<span class="number">11</span>:<span class="number">11</span> CST</span><br><span class="line">[root@localhost ~]<span class="comment"># date -s &quot;20201111 11:11:11&quot;</span></span><br><span class="line"><span class="number">2020</span>年 <span class="number">11</span>月 <span class="number">11</span>日 星期三 <span class="number">11</span>:<span class="number">11</span>:<span class="number">11</span> CST</span><br><span class="line">​</span><br><span class="line">[root@localhost ~]<span class="comment"># date +%F</span></span><br><span class="line"><span class="number">2020</span>-<span class="number">11</span>-<span class="number">11</span></span><br><span class="line">[root@localhost ~]<span class="comment"># date +%T</span></span><br><span class="line"><span class="number">11</span>:<span class="number">11</span>:<span class="number">29</span></span><br></pre></td></tr></table></figure>

<h3 id="再看看备份"><a href="#再看看备份" class="headerlink" title="再看看备份"></a>再看看备份</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># tar czvf `date +%F`_bak.tar.gz /etc</span></span><br><span class="line"><span class="comment"># tar czvf `date +%F_%H_%M_%S`_bak.tar.gz /etc  # 如果带有时分秒，不要用冒号分隔，因为文件名的命名里不能带有冒号</span></span><br></pre></td></tr></table></figure>



<h1 id="7-文件系统（操作系统某个组件）"><a href="#7-文件系统（操作系统某个组件）" class="headerlink" title="7.文件系统（操作系统某个组件）"></a>7.文件系统（操作系统某个组件）</h1><h2 id="7-1-文件系统介绍"><a href="#7-1-文件系统介绍" class="headerlink" title="7.1 文件系统介绍"></a>7.1 文件系统介绍</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">文件是操作系统提供给用户、应用程序操作硬盘的一种功能</span><br><span class="line">文件系统是操作系统内核中负责组织管理硬盘的程序，文件系统提供了文件这种功能</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="7-1-1文件系统的种类："><a href="#7-1-1文件系统的种类：" class="headerlink" title="7.1.1文件系统的种类："></a>7.1.1文件系统的种类：</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">linux系统：文件系统</span><br><span class="line">ext3</span><br><span class="line">ext4</span><br><span class="line">xfs    SentOS <span class="number">7</span>默认 xfs 和 btrfs 相比较ext3/<span class="number">4</span>而言，在高伸缩性数据存储方面具有优势</span><br><span class="line">btrfo</span><br><span class="line">windows系统：文件系统</span><br><span class="line">FAT32</span><br><span class="line">NTFS</span><br></pre></td></tr></table></figure>



<h2 id="7-2-文件系统工作原理"><a href="#7-2-文件系统工作原理" class="headerlink" title="7.2 文件系统工作原理"></a>7.2 文件系统工作原理</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 文件是由两部分内容组成：</span></span><br><span class="line"><span class="number">1</span>、文件的元信息，例如权限（rwx）、拥有者、群组、时间参数等</span><br><span class="line"><span class="number">2</span>、文件的实际内容</span><br><span class="line"><span class="comment"># 文件系统通常将这两部分的内容分别存放在不同的区块：</span></span><br><span class="line"><span class="number">1</span>、文件的元信息放置到  inode区块中</span><br><span class="line"><span class="number">2</span>、文件的实际内容则放置到 data block区块中</span><br><span class="line"><span class="comment"># 每个inode 与 block 都有自己的编号</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># superblock 会记录整个档案系统的整体信息，包括inode与blicj的总量、使用量、剩余量等</span></span><br><span class="line"></span><br><span class="line">磁盘的最小存储单位叫做<span class="string">&#x27;扇区&#x27;</span> <span class="number">512</span>字节，文件系统将<span class="number">8</span>个<span class="string">&#x27;扇区&#x27;</span>组织成一个<span class="string">&#x27;block&#x27;</span>块，一次读取一个<span class="string">&#x27;block&#x27;</span>块，即<span class="number">8</span>个扇区，是文件存取的最小单位</span><br></pre></td></tr></table></figure>

<h2 id="7-3-inode号码"><a href="#7-3-inode号码" class="headerlink" title="7.3 inode号码"></a>7.3 inode号码</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">inode负责存储文件的元信息：</span><br><span class="line"><span class="number">1</span>、 inode编号</span><br><span class="line"><span class="number">2</span>、用识别文件类型，以及用于 stat c函数的模式信息</span><br><span class="line"><span class="number">3</span>、连接数，即有多少文件名指向这个inode</span><br><span class="line"><span class="number">4</span>、属主的ID（UID）</span><br><span class="line"><span class="number">5</span>、属主的组ID (GID)</span><br><span class="line"><span class="number">6</span>、文件的字节数</span><br><span class="line"><span class="number">7</span>、文件所使用的磁盘块的实际数目</span><br><span class="line"><span class="number">8</span>、文件的时间戳。共有三个：ctime指inode上一次变动的时间，mtime指文件内容上一次变动的时间，atime指文件上一次打开的时间</span><br><span class="line"><span class="number">9</span>、指向数据块的指针</span><br><span class="line"><span class="comment">#  stat查看某个文件的inode信息</span></span><br><span class="line"><span class="comment">#  每个文件都必须有一个inode，有可能发生inode已经用光，但是硬盘没满，这时，就无法在硬盘上创建新文件</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="7-3-1-inode的大小"><a href="#7-3-1-inode的大小" class="headerlink" title="7.3.1 inode的大小"></a>7.3.1 inode的大小</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">inode 会消耗硬盘空间，所以硬盘格式化的时候，操作系统自动将硬盘分成两个区域，一个是数据区，存放文件数据，另一个是inode区（inode table），存放inode所包含的信息1GB硬盘，每个inode节点大小为<span class="number">128</span>字节，每1kb设置一个inode，那么inode table大小就会达到128MB，占整块硬盘的<span class="number">12.8</span>%</span><br></pre></td></tr></table></figure>



<h3 id="7-3-2-目录项"><a href="#7-3-2-目录项" class="headerlink" title="7.3.2 目录项"></a>7.3.2 目录项</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">目录文件的结构非常简单，就是一系列目录项的列表，每个目录项，由两部分组成：所包含文件的文件名，以及该文件名对用的inode号码</span><br><span class="line">ls /etc  指列出目录文件中的所有文件名</span><br><span class="line"><span class="comment"># ls -i 列出整个目录文件，文件名和inode号码</span></span><br><span class="line"><span class="comment"># ls -di 列出目录文件，文件名和inode号码</span></span><br><span class="line"><span class="comment">#ls -l 查看文件详细信息</span></span><br></pre></td></tr></table></figure>

<h3 id="7-3-3-FAT文件系统"><a href="#7-3-3-FAT文件系统" class="headerlink" title="7.3.3 FAT文件系统"></a>7.3.3 FAT文件系统</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">U盘档案系统为FAT格式，没有inode号码存在，所以没有办法一下子将档案的所有block一开始就读出来，当他们不在一个block块过于分散的时候，磁盘只有多转几圈才能全部读取。碎片整理可以解决这个问题，将分散的信息整理到一个档案所属的blocks会正在一起，读取比较容易</span><br></pre></td></tr></table></figure>

<h2 id="7-4-inode的特殊作用"><a href="#7-4-inode的特殊作用" class="headerlink" title="7.4 inode的特殊作用"></a>7.4 inode的特殊作用</h2><figure class="highlight py"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">由于inode号码与文件名分离，导致了一些Unix/Linux系统特有的现象：</span><br><span class="line"><span class="number">1.</span>有时，文件名包含特殊字符，无法正常删除，这是，直接删除inode节点，可以删除文件。</span><br><span class="line"><span class="number">2.</span>移动文件或重命名文件，只是改变文件名，不影响inode号码</span><br><span class="line"><span class="number">3.</span>打开一个文件以后，系统就医inode号码来识别这个文件，不在考虑文件名。因此，通常来说，系统无法从inode号码得知文件名</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="7-5-硬链接和软连接"><a href="#7-5-硬链接和软连接" class="headerlink" title="7.5 硬链接和软连接"></a>7.5 硬链接和软连接</h3><h4 id="7-5-1硬链接知识提炼"><a href="#7-5-1硬链接知识提炼" class="headerlink" title="7.5.1硬链接知识提炼"></a>7.5.1硬链接知识提炼</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>对硬链接文件内容进行修改，会影响到所有文件名；</span><br><span class="line"><span class="number">2.</span>硬链接文件与源文件具有相同inode的不同文件名：一个文件只能有一个inode号，但多个文件的inode号可以相同</span><br><span class="line"><span class="number">3.</span>删除硬链接或者源文件之一，不影响另一个文件名的访问，除非所有的都删除掉，所以硬链接的作用是允许一个文件拥有多个有效路径名，可以建立硬链接到重要文件，防止误删</span><br><span class="line"><span class="number">4.</span>删除所有硬链接，数据会在被磁盘检查或者新数据写入的时候删除回收</span><br><span class="line"><span class="number">5.</span>通过Ln [源文件][目标文件]设置硬链接</span><br><span class="line"><span class="number">6.</span>通过rm -f 删除硬链接</span><br><span class="line"><span class="number">7.</span>目录不可创建硬链接，并且硬链接无法跨区</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="7-5-2-软连接知识提炼"><a href="#7-5-2-软连接知识提炼" class="headerlink" title="7.5.2 软连接知识提炼"></a>7.5.2 软连接知识提炼</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>对软连接的源文件或者目标文件进行修改，会影响到所有文件名</span><br><span class="line"><span class="number">2.</span>软连接文件与源文件具有不同的inode号</span><br><span class="line"><span class="number">3.</span>删除软连接文件的源文件，软连接文件将无法使用。</span><br><span class="line"><span class="comment">#  软连接作用</span></span><br><span class="line">   <span class="number">1.</span>软件升级</span><br><span class="line">    <span class="number">2.</span>企业代码发布</span><br><span class="line">     <span class="number">3.</span>不方便目录移动</span><br><span class="line"><span class="number">4.</span>删除源文件后，软连接文件无效，应该也一起删除掉，方便回收</span><br><span class="line"><span class="number">5.</span>执行Ln -s [源文件][目标文件]创建软连接</span><br><span class="line"><span class="number">6.</span>rm -f 删除软连接</span><br><span class="line"><span class="number">7.</span> 可以对目录创建软连接，并且软连接可以跨分区</span><br></pre></td></tr></table></figure>

<h1 id="其他场景"><a href="#其他场景" class="headerlink" title="其他场景"></a>其他场景</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>大量的小文件问题：可能会是inode耗尽，是的文件无法创建。磁盘利用率低。对于小文件比较多的场景，<span class="comment">#  将block划分小一点</span></span><br><span class="line"><span class="number">2.</span>大文件问题：一个文件占用多个block，是的文件读写速率慢。</span><br><span class="line"><span class="comment"># 将block划分大一点</span></span><br></pre></td></tr></table></figure>



<h1 id="企业面试题"><a href="#企业面试题" class="headerlink" title="企业面试题"></a>企业面试题</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>从定义：linux系统中，链接有两种，一种被称为软连接，类似一快捷方式，存放指向源文件inode的信息，与源文件inode不同，一种是硬链接，与源文件有相同inode，可以z数据的block</span><br><span class="line"><span class="number">2.</span>从创建方式：硬链接命令ln [源文件][目标文件]，软连接命令ln -s[原文件][目标文件]</span><br><span class="line"><span class="number">3.</span>从创建对象：ln命令不能对目录创建硬链接，但是可以对目录创建软连接。因为软连接可以跨越文件系统，硬链接不能。对目录和为客户创建的文件软连接经常用到</span><br><span class="line"><span class="number">4.</span>删除软连接文件，对硬链接和源文件无影响</span><br><span class="line"><span class="number">5.</span>删除文件硬链接，对源文件及链接文件无影响</span><br><span class="line"><span class="number">6.</span>删除源文件，对硬链接读取数据无影响，软连接则失效。会出现红底白字状</span><br><span class="line"><span class="number">7.</span>同时删除源文件和硬链接，源文件才会被真正删除</span><br><span class="line"><span class="number">8.</span>很多硬件设备中的快照原理，类似于硬链接原理</span><br><span class="line"></span><br></pre></td></tr></table></figure>


            </div>

            <!-- Post Comments -->
            
    <!-- 使用 DISQUS_CLICK -->
<div id="disqus-comment">
    <div id="disqus_thread"></div>

<!-- add animation -->
<style>
	.disqus_click_btn {
            line-height: 30px;
            margin: 0;
            min-width: 50px;
            padding: 0 14px;
            display: inline-block;
            font-family: "Roboto", "Helvetica", "Arial", sans-serif;
            font-size: 14px;
            font-weight: 400;
            text-transform: uppercase;
            letter-spacing: 0;
            overflow: hidden;
            will-change: box-shadow;
            transition: box-shadow .2s cubic-bezier(.4, 0, 1, 1), background-color .2s cubic-bezier(.4, 0, .2, 1), color .2s cubic-bezier(.4, 0, .2, 1);
            outline: 0;
            cursor: pointer;
            text-decoration: none;
            text-align: center;
            vertical-align: middle;
            border: 0;
            background: rgba(158, 158, 158, .2);
            box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
            color: #fff;
            background-color: #7EC0EE;
            text-shadow: 0
        }
</style>
	
<div class="btn_click_load" id="disqus_bt"> 
    <button class="disqus_click_btn">点击查看评论</button>
</div>

<!--
<script type="text/javascript">
$('.btn_click_load').click(function() {
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'http-miccall-tech'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();

    document.getElementById('disqus_bt').style.display = "none";
});
</script>
-->
<script type="text/javascript">
    var disqus_config = function () {
        this.page.url = 'https://gitee.com/AmeX/amelin-ting.git/2017/04/02/%E7%B3%BB%E7%BB%9FLinux%E5%9F%BA%E7%A1%80/';  // Replace PAGE_URL with your page's canonical URL variable
        this.page.identifier = 'https://gitee.com/AmeX/amelin-ting.git/2017/04/02/%E7%B3%BB%E7%BB%9FLinux%E5%9F%BA%E7%A1%80/'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
</script>

<script type="text/javascript">
    $('.btn_click_load').click(function() {  //click to load comments
        (function() { // DON'T EDIT BELOW THIS LINE
            var d = document;
            var s = d.createElement('script');
            s.src = '//http-miccall-tech.disqus.com/embed.js';
            s.setAttribute('data-timestamp', + new Date());
            (d.head || d.body).appendChild(s);
        })();
        $('.btn_click_load').css('display','none');
    });
</script>
</div>
<style>
    #disqus-comment{
        background-color: #eee;
        padding: 2pc;
    }
</style>


        </div>
        <!-- Copyright 版权 start -->
                <div id="copyright">
            <ul>
                <li>&copy;Powered By <a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/" style="border-bottom: none;">hexo</a></li>
                <li>Design: <a target="_blank" rel="noopener" href="http://miccall.tech " style="border-bottom: none;">miccall</a></li>
            </ul>
            
                <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
			
        </div>
    </div>
</body>



 	
</html>
